package cn.tedu.cgb2202.sk.common.ex.handler;

import cn.tedu.cgb2202.sk.common.ex.ServiceException;
import cn.tedu.cgb2202.sk.common.web.JsonResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 2022.6.14
 * 胡然
 * 该类用于统一处理全局异常
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(ServiceException.class)
    public JsonResult<Void> handleServiceException(ServiceException exception){
        return JsonResult.fail(exception.getState(),exception.getMessage());
    }
}
